package com.thrc.borrow.utils;

import java.io.InputStream;
import java.util.Properties;
import org.apache.commons.lang.StringUtils;

public class PropertiesUtil {

	public static class KEY{
		public static final String FILE_UPLOAD_PATH = "upload";
	}

	public static String getKey(String key) {
		return getKey(key, "-");
	}

	public static String getKey(String key, String defaultValue) {
		String retkey = read(key);
		if (StringUtils.isEmpty(retkey))
			return defaultValue;
		return retkey;
	}

	private static String read(String key) {

		try {
			InputStream in = PropertiesUtil.class.getClassLoader()
					.getResourceAsStream("conf.properties");
			Properties p = new Properties();
			p.load(in);

			return p.getProperty(key);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;

	}
}
